﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Logic;
using Entities;

namespace MusicDeskTop
{
    public partial class MainForm : Form
    {
        private Disk disk = new Disk();

        public MainForm()
        {
            InitializeComponent();
        }

        private void addTrack_Click(object sender, EventArgs e)
        {
            TrackForm form = new TrackForm();
            form.ShowDialog();

            AbstractTrack track = form.GetTrack();
            if (track != null)
            {
                disk.Add(track);
                Refresh(disk);

                DiscLogic discLogic = new DiscLogic();
                int length = discLogic.GetLength(disk);
                lengthLabel.Text = length.ToString();
            }         
        }

        private void Refresh(Disk disk)
        {
            this.trackListBox.Items.Clear();

            foreach (AbstractTrack track in disk.Tracks)
            {
                this.trackListBox.Items.Add(track);
            }
        }

        private void exitButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
